﻿using System;

namespace YouTrackSharp.Issues
{
    public static class YouTrackTimeConverter
    {
        private static readonly DateTime _originTime = DateTime.Parse("1970-01-01 00:00:00").AddHours(8);

        public static double DateTimeToValue(DateTime? time)
        {
            if (time == null)
            {
                return 0;
            }
            return (time.Value - _originTime).Milliseconds;
        }
        
        public static DateTime ValueToDateTime(double value)
        {
            return _originTime.AddMilliseconds(value);
        }
    }
}